using UnityEngine;
using System.Collections;
using AnimationOrTween;

public class PrintAction : PrintEffect
{
	public bool enable;
	public ActionInvoker actionInvoker;
	
	override protected void Update ()
	{
		if (enable) {
			base.Update ();
		}
	}
	
	override protected void initAction ()
	{
		Destroy (actionInvoker);
	}
	
	override protected void doAction (GameObject go)
	{
		if (actionInvoker != null) {
			ActionInvoker invoker = go.GetComponent (actionInvoker.GetType ()) as ActionInvoker;
			if (invoker == null) {
				go.AddComponent (actionInvoker.GetType ());
				invoker = go.GetComponent (actionInvoker.GetType ())  as ActionInvoker;
				CommonUtils.clone (actionInvoker, invoker);
			}
			
			invoker.run (printDuration);
		}
	}
	
	override protected void completeAction ()
	{
		enable = false;
	}
}
